package com.android.multiplesmart.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.android.multiplesmart.R;
import com.android.multiplesmart.bean.MianReBean;
import com.android.multiplesmart.utils.QrCodeUtil;

import java.util.List;

public class Tar_CouresAdapter extends RecyclerView.Adapter<Tar_CouresAdapter.TarViewHolder> {

    private Context context;
    private List<String> mData;
    public Tar_CouresAdapter(Context context, List<String> mData) {
        this.context = context;
        this.mData = mData;
    }


    @NonNull
    @Override
    public TarViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.couresitem,  parent, false);
        return new TarViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull TarViewHolder holder, int position) {
        holder.code.setImageBitmap(QrCodeUtil.createQRCode(mData.get(position),150,150));
    }

    @Override
    public int getItemCount() {
        return mData.size();
    }

    public class  TarViewHolder extends RecyclerView.ViewHolder{
        ImageView code;

        public TarViewHolder(@NonNull View itemView) {
            super(itemView);
            code= itemView.findViewById(R.id.code);
        }

    }

}